﻿@model  List<FTBS.Models.Entities.Film> 

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<body onload="loadAllTheaterOfFirstFilm(@Model[0].FilmId)">
    <div style="overflow: auto; background-color: #4390df !important; padding-top: 15px">
        <div style="float: left; margin-left: 13px; overflow:auto;">
            <img src="~/Image/Theater/film_icon.png" style="width:40px; height:40px; float: left;"/>
            <h2 style="color: black !important; font-weight: bold; float: left; margin-left:10px">PHIM</h2>
        </div>
        <div style="float: left; padding-left: 288px; overflow:auto">
            <img src="~/Image/Theater/HouseBlack.png"  style="width:40px; height:40px; float: left;"/>
            <h2 style="color: black !important; font-weight: bold; float: left; margin-left:10px">RẠP CHIẾU</h2>
        </div>
        <div style="float: left; padding-left: 215px; overflow:auto">
            <img src="~/Image/Theater/clock.png"  style="width:40px; height:40px; float: left;"/>
            <h2 style="color: black !important; font-weight: bold; float: left; margin-left:10px">GIỜ CHIẾU</h2>
        </div>
    </div>

    <div style="overflow: auto; background-color: white; margin-top: 10px">
        <div style="float: left; height: 500px; width: 400px; overflow-x: auto; border-right:solid 1px #4390df">
            <div class="grid">
                @foreach (var film in Model)
                {
                    <div class="row">
                        <div class="span5">
                            <div class="listview">
                                <a href="#" class="list" id="filmItem @film.FilmId"  onclick="ChangeType(@film.FilmId)">
                                    <div class="list-content" onclick="loadTheaterByFilmId(@film.FilmId)">
                                        <img src="~/Image/FilmImage/@film.ImageURL" class="icon" />
                                        <div class="data">
                                            <span class="list-title">@film.Name</span>
                                            <button class="button mini danger">@film.Format.FormatName</button>
                                            <div class="rating small no-margin" data-role="rating" data-stars="5">
                                                <ul style="margin-bottom: 0px;">
                                                    <li></li>
                                                    <li></li>
                                                    <li></li>
                                                    <li></li>
                                                    <li></li>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </a>
                            </div>
                        </div>
                    </div>
            }
            </div>
        </div>

        <div style="float: left; height: 500px; width: 400px; overflow-x: auto;">
            <div id="listTheater">
                @Html.Partial("TheatersByFilm", (List<FTBS.Models.Entities.Theater>)ViewBag.ListTheater)
            </div>
        </div>
        <div style="float: left; height: 500px; width: 400px; overflow-x: auto;">
            <div id="listShowTime">
                @Html.Partial("ShowTimeOfTheater", (List<FTBS.Models.Entities.ShowTime>)ViewBag.ListShowTime)
            </div>

        </div>
    </div>
</body>



<script>
    function loadAllTheaterOfFirstFilm(idOfFilm) {
        $.ajax({
            url: "/Schedule/TheatersByFilm",
            type: "GET",
            data: { filmId: idOfFilm },
            success: function (data) {
                $('#listTheater').html(data);
            },
            error: function (data) {
                alert("fail");
            }
        });
    }

    function ChangeType(filmId) {
        var idTag = "filmItem" + " " + filmId;
        document.getElementById(filmId)
        var classValue = document.getElementById(idTag).getAttribute("class");
        
        if (classValue == "list selected") {
            document.getElementById(idTag).setAttribute("class", "list");
        }
        else {
            $("a[id^='filmItem']").attr('class', 'list');
            document.getElementById(idTag).setAttribute("class", "list selected");
        }
        
    }
</script>


